var request=require('request');


var main=(()=>{
    var self,config;
    return {
        init:function (opts) {
            config=opts;
            self=this;
            self.fetch();
        },
        fetch:async ()=>{
            var body=await new Promise((resolve,reject)=>{
                request()
            });
            console.log('body:',body);
        }
    }
})();

main.init({
    apiUrl:'http://www.66ip.cn/mo.php?sxb=&tqsl=100&port=&export=&ktip=&sxa=&submit=%CC%E1++%C8%A1&textarea=http%3A%2F%2Fwww.66ip.cn%2F%3Fsxb%3D%26tqsl%3D100%26ports%255B%255D2%3D%26ktip%3D%26sxa%3D%26radio%3Dradio%26submit%3D%25CC%25E1%2B%2B%25C8%25A1'
});


function proxy(proxyurl) {

    var targetOptions = {
        method: 'GET',
        url: 'http://ip.chinaz.com/getip.aspx',
        timeout: 8000,
        encoding: null,
    };

    //这里修改一下，变成你要访问的目标网站
    //proxyList.forEach(function (proxyurl) {

        console.log(`Testing ${proxyurl}`);

        targetOptions.proxy = 'http://' + proxyurl;
        request(targetOptions, function (error, response, body) {
            if(error)return console.error(error);

            console.log('验证成功:',body.toString());
        });

    //});
}

//proxy('69.75.205.68');